﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MO.ModelingClient
{
    public partial class QueryTemplateForm : Form
    {
        public QueryTemplateForm()
        {
            InitializeComponent();
        }

        private void QueryTemplateForm_Shown(object sender, EventArgs e)
        {
            DataConfig config = new DataConfig();
            config.TableName = "Query_Template";
            config.KeyField = "QT_Code";
            config.TitleField = "QT_Name";
            config.OrderField = "QT_Order";
            config.AddItem(new ItemData("QT_Code", "编码"));
            config.AddItem(new ItemData("QT_Name", "名称"), true);
            config.AddItem(new ItemData("QT_Description", "描述"));
            config.AddItem(new ItemData("QT_Order", "排序") { Type = DataType.Number });
            config.AddItem(new ItemData("Query_Column", "列口径")
            {
                Type = DataType.ChildTable,
                IsDd = false,
                ChildConfig = GetQueryColumnConfig()
            });
            config.AddItem(new ItemData("QT_Query_Condition", "查询条件"));
            config.AddItem(new ItemData("QT_Order_Condition", "排序条件"));
            config.AddItem(new ItemData("QT_Query_Script", "2次查询脚本"));
            config.AddItem(new ItemData("QT_Tree_Show", "树型显示") { Type = DataType.Bool });
            tableControl1.Init(config);
        }
        DataConfig GetQueryColumnConfig()
        {
            DataConfig config = new DataConfig();
            config.TableName = "Query_Column";
            config.KeyField = "QC_Code";
            config.TitleField = "QC_Name";
            config.OrderField = "QC_Order";
            config.AddItem(new ItemData("QC_Code", "编码"));
            config.AddItem(new ItemData("QC_Name", "名称"),true);
            config.AddItem(new ItemData("FD_Code", "关联指标") { Type = DataType.Field });
            config.AddItem(new ItemData("QC_Format", "显示格式"));
            config.AddItem(new ItemData("QC_Order", "排序") { Type = DataType.Number });
            return config;
        }
    }
}
